package com.meitianhui.convenitenbuy.util;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.meitianhui.convenitenbuy.R;

/**
 * Created by amy on 2017/11/8.
 */

public class GlideUtils {

    /**
     * 设置圆形图片
     */
    public static void setUserCircleImage(Context context, String path, ImageView imageView) {
        Glide.with(context)
                .load(path)
                .apply(new RequestOptions()
                        .placeholder(R.mipmap.user_person)
                        .fitCenter()
                        .apply(RequestOptions.circleCropTransform())
                        .error(R.mipmap.user_person))
                .into(imageView);
    }

    public static void setCircleImage(Context context, String path, int place,
                                      int error, ImageView imageView) {
        Glide.with(context)
                .load(path)
                .apply(new RequestOptions()
                        .placeholder(place)
                        .fitCenter()
                        .apply(RequestOptions.circleCropTransform())
                        .error(error))
                .into(imageView);
    }

    public static void setRectImage(Context context, String path, ImageView imageView) {
        Glide.with(context)
                .load(path)
                .apply(new RequestOptions()
                        .placeholder(R.mipmap.icon_default_picture)
                        .error(R.mipmap.icon_default_picture)
                        .fitCenter())
                .into(imageView);
    }

    public static void setRectImage(Context context, String path, int place,
                                    int error, ImageView imageView) {
        Glide.with(context)
                .load(path)
                .apply(new RequestOptions()
                        .placeholder(place)
                        .error(error)
                        .fitCenter())
                .into(imageView);
    }

}
